<p id="notice"><%= notice %></p>
<table border="0">
<tr>
<td width="630">

<h2>Event Info</h2>
<p>
  <b>Name:</b>
  <%= @event.name %>
</p>

<p>
  <b>Author:</b>
  <%= @event.author %>
</p>

<p>
  <b>Description:</b>
  <%= @event.description %>
</p>

<p>
  <b>Start Date and Time:</b>
  <%= @event.starts_at.to_formatted_s(:long_ordinal) %>
</p>

<p>
  <b>Location:</b>
  <%= @event.location %>
</p>

</td>
<td width="630">
<p>
  <img src=" 
  <% @loc =  Location.where("event_id = ?", @event.id) %>
  <% if !@loc.first.nil?  %>
  <%= @loc.first.gmapString.to_s %>
  <% end %>
  " alt="No Map" />
</p>

</td>

</tr>

<tr>
<td width="630">

<% if session[:user].id == @event.author_id %>   
    <h2>Invitees</h2>
    <%= form_for :event, :url => {:action => "checkAttendence" } do |f| %>
    <table>
    <tr>
        <th>First Name</th>
        <th>Last Name</th>
	<th>Attended?</th>
	<th>Attended?</th>
    </tr>
    <input type="hidden" name="eid" value="<%= @event.id %>"/>    
    <% @invitees = InviteeList.all %>
    <% @invitees.each do |invitee| %>
        <% if invitee.event_id == @event.id %>
            <tr>
                <td><%= User.find(invitee.user_ids).first_name %></td>
                <td><%= User.find(invitee.user_ids).last_name %></td>
                <td><%= check_box_tag "invitees["+invitee.user_ids.to_s+"]", 'yes', invitee.attended %> 
		<% if invitee.attended %>
			<td>Attended</td>
		<% else %>
			<td>Did Not Attend</td>
		<% end %>
		<br />
		
            </tr>
        <% end %>
    <% end %>
    </table> 
    <%= submit_tag "Update Attendence!" %>
    <% end %>
<% else%>
    <% if session[:user].authority != "user" %>
        <h2>Invitees</h2>
        <table>
        <tr>
            <th>First Name</th>
            <th>Last Name</th>
        </tr>
                
        <% @invitees = InviteeList.all %>
        <% @invitees.each do |invitee| %>
            <% if invitee.event_id == @event.id %>
                <tr>
                    <td><%= User.find(invitee.user_ids).first_name %></td>
                    <td><%= User.find(invitee.user_ids).last_name %></td><br />
                </tr>
            <% end %>
        <% end %>
        </table>
    <% end %>
<% end %>

</td>

<td width="630">

<h2>Responses</h2>
<% @event.responses.each do |response| %>
  <p>
    <b>User:</b>
    <%= response.commenter %>
  </p>
  <p>
    <b>Response:</b>
    <%= response.body %>
  </p>
<% end %>

<h2>Respond to the Event:</h2>
<%= form_for([@event, @event.responses.build]) do |f| %>
  <div class="field">
    <%= f.label :commenter %><br />
    <%= session[:user].first_name + " " + session[:user].last_name%>
    <input type="hidden" name="response[commenter]" value="<%= session[:user].first_name+ ' ' + session[:user].last_name %>"/>
  </div>
  <div class="field">
    <%= f.label :body %><br />
    <%= f.text_field :body %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %> 

</td>

</tr>

</table> 
<% if session[:user].id == @event.author_id %>
	<%= link_to 'Edit', edit_event_path(@event) %>
<% end %>